﻿@{
    ViewData["Title"] = "评论管理";
    ViewData["BreadCrumb"] = "主页 / 评论管理";
}

@section toolbar{
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <input type="text" name="poster" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-forum-list" lay-submit="" lay-filter="LAY-app-forumlist-search">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
        </div>
    </div>
}
<script type="text/html" id="toolbarDemo">
</script>
<table class="layui-hide" id="myTable" lay-filter="myTable" lay-even=""></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="check">审核</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
@section scripts{

    <script>
        layui.config({
            version: "3.0.0"
            , base: '/res/mods/'
        }).extend({
            fly: 'index'
        }).use(['fly','table'], function () {
            var table = layui.table
                , fly = layui.fly;
            //第一个实例
            table.render({
                elem: '#myTable'
                , url: '@Url.Content("~/Comment/List")' //数据接口
                , method: 'post'
                , page: true //开启分页
                , limit: 10
                , cellMinWidth: 150
                , toolbar: '#toolbarDemo'
                , title: '数据列表'
                , cols: [[ //表头
                      { field: 'id', title: 'ID', sort: true,width: 80 }
                    , { field: 'content', title: '内容', sort: true }
                    , { field: 'likeCount', title: '点赞', sort: true }
                    , { field: 'articleId', title: '文章', sort: true }
                    , { field: 'ip', title: 'IP', sort: true }
                    , { field: 'createDateTime', title: '创建时间', sort: true }
                    , { field: 'isVisible', title: '是否显示', sort: true }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 230 }
                ]]
            });
            //监听行工具事件
            table.on('tool(myTable)', function (obj) {
                var data = obj.data;
                //console.log(obj)
                switch (obj.event) {
                    //审核
                    case 'check':
                        {
                            layer.confirm('确定审核通过？', function (index) {
                                fly.json('@Url.Content("~/Comment/Check")', { 'id': data.id }, function (res) {
                                    layer.msg(res.msg);
                                });
                                //window.location.reload();
                                window.location = window.location;
                            });
                        } break;
                    //删除
                    case 'del':
                        {
                            layer.confirm('真的删除行么', function (index) {
                                fly.json('@Url.Content("~/Comment/Del")', { 'id': data.id }, function (res) {
                                    layer.msg(res.msg);
                                    });
                                obj.del();
                                layer.close(index);
                            });
                        } break;

                }

            });

        });
    </script>

}